package com.jason.jpa.web;

import com.jason.jpa.exceptions.MyException;
import com.jason.jpa.exceptions.MyException2;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * Created by Jason on 2018-04-26.
 */
@Controller
@RequestMapping("/exceptions")
public class ExceptionController {

    @RequestMapping("/")
    public String hello() throws MyException2 {
        System.out.println("a");
        if (true)
            throw new MyException2("统一异常处理测试！");
        return "error";
    }

    @RequestMapping("/2")
    @ResponseBody
    public String hello2() throws MyException {
        System.out.println("a");
        if (true)
            throw new MyException("统一异常处理测试！");
        return "error";
    }
}
